Imports System.Diagnostics
Imports System.Data.SqlClient


Partial Class MasterPage_Default
    Inherits System.Web.UI.Page

    
    Private _nazevProdejce As String
    Public Property nazevProdejce() As String
        Get
            _nazevProdejce = TXB_Filtrnazev.Text
            Return _nazevProdejce
        End Get
        Set(ByVal value As String)
            _nazevProdejce = value
        End Set
    End Property



    Private Function nastavFiltrProdejce() As String
        Dim sb As StringBuilder = New StringBuilder()

        sb.Append(DS_Prodejci.SelectCommand)



        If (nazevProdejce <> "") Then
            sb.Append(" AND T_Prodejci.Nazev like '%")
            sb.Append(nazevProdejce)
            sb.Append("%'")
        End If



        Return sb.ToString
    End Function


    Protected Sub FV_Produkty_ModeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles FV_Prodejci.ModeChanged
        DS_Prodejci.SelectCommand = nastavFiltrProdejce()
        DS_Prodejci.DataBind()
    End Sub

    
    Protected Sub ddl_pageSize_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddl_pageSize.SelectedIndexChanged
        GV_Prodejci.PageSize = ddl_pageSize.SelectedValue
        DS_Prodejci.SelectCommand = nastavFiltrProdejce()
    End Sub

    Protected Sub DS_Produkty_Deleted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceStatusEventArgs) Handles DS_Prodejci.Deleted
        DS_Prodejci.DataBind()
        FV_Prodejci.DataBind()
    End Sub

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        FV_Prodejci.ChangeMode(FormViewMode.Insert)
    End Sub


    Protected Sub GV_Produkty_PageIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GV_Prodejci.PageIndexChanged
        DS_Prodejci.SelectCommand = nastavFiltrProdejce()
        DS_Prodejci.DataBind()
    End Sub

 
    Protected Sub BTN_najdiObjcis_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BTN_najdiProdejce.Click
        DS_Prodejci.SelectCommand = nastavFiltrProdejce()
        DS_Prodejci.DataBind()
    End Sub

End Class
